package com.hmall.item.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {
    /**
     * 交换机
     */
    @Bean
    public DirectExchange exchange(){
        return new DirectExchange("hmall.direct");
    }
    /**
     * 创建队列
     */
    @Bean
    public Queue directQueue1(){
        return new Queue("hmall.insert",true);
    }
    @Bean
    public Queue directQueue2(){
        return new Queue("hmall.delete",true);
    }
    @Bean
    public Binding binding(){
        return BindingBuilder.bind(directQueue1()).to(exchange()).with("insert");
    }
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(directQueue2()).to(exchange()).with("delete");
    }
}
